<script setup>
import { useRouter, useRoute } from "vue-router";
import { usePermissionStore } from "@/store/permission.store.js";

const router = useRouter();
const route = useRoute();

//国际化
let lang = navigator.language;
if (lang == "en" || lang.toLowerCase == "en-us") {
  document.getElementById("desc").innerHTML = `
                You encountered a 404 error. It means that the resource you are accessing does not exist on the server. <br>
                If you jumped to this page by entering a URL, please check whether there is any typo in the URL. <br>
                If you jumped to this page by clicking the link in the official page, please <a href = "mailto:youmail@example.com" class="contat">contact us</a>.<br>`;
  document.getElementById("subtitle").innerHTML = "Page Not Found";
  document.title = "404 Not Found";
  document.getElementById("link").innerHTML = "Back to home";
}

const back = () => {
  router.push({ path: usePermissionStore().activeMenu || "/" });
};
</script>

<template>
  <div class="container">
    <div class="main_box">
      <div class="title">
        404
        <div class="line"></div>
      </div>
      <div class="subtitle" id="subtitle">页面不存在</div>
      <div class="desc" id="desc">
        您遇到了404错误。它意味着您所访问的资源在服务器上不存在。
        <br />
        如果您是通过输入网址而跳转到此界面，请检查您输入的网址。
        <br />
        如果您是由点击官方页面上的链接而跳转到此界面，请
        <a href="mailto:2902344492@qq.com" class="contat">联系我们</a>
        。
        <br />
      </div>
      <div class="btn" @click="back()">
        <a class="return" id="link">返回</a>
      </div>
    </div>
  </div>
</template>

<style scoped>
.container {
  --theme_color: rgb(255, 75, 75);
  --theme_color_light: rgb(255, 249, 248);
  transition: 0.3s;
  height: 100%;
  width: 100%;
  background-color: #fff;
}
.title {
  font-size: 180px;
  font-weight: 100;
  margin-top: 200px;
  color: var(--theme_color);
  line-height: 180px;
}
.main_box {
  max-width: 100%;
  margin-left: 15%;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft Yahei", Helvetica, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}
.line {
  height: 10px;
  color: var(--theme_color_light);
  border-top: 5px solid;
  width: 100px;
  margin-top: 10px;
  margin-left: 5px;
}
.subtitle {
  font-size: 24px;
  margin-left: 4px;
  font-weight: 700;
}
.desc {
  color: #000;
  font-size: 16px;
  margin-left: 10px;
}
.btn {
  display: inline-block;
  margin-top: 50px;
  padding: 12px 28px;
  background-color: var(--theme_color);
  border-radius: 6px;
  color: white;
  font-size: 18px;
  text-decoration: none;
  transition: 0.25s;
  cursor: pointer;
  margin-left: 4px;
}
.btn:hover {
  background-color: var(--theme_color_light);
}
.contat {
  color: #000000;
}
.return {
  color: #ffffff;
  text-decoration: none;
}
@media (prefers-color-scheme: dark) {
  body {
    background: rgb(22, 22, 22);
    color: white;
  }
  .desc {
    color: rgba(255, 255, 255, 0.666);
  }
  .contat {
    color: #ffffff;
  }
}
@media screen and (max-width: 700px) {
  .title {
    font-size: 120px;
    line-height: 120px;
    margin-top: 50px;
  }
  .main_box {
    margin-right: 5%;
    margin-left: 5%;
  }
}
@media screen and (max-height: 800px) {
  .title {
    font-size: 120px;
    line-height: 120px;
    margin-top: 50px;
  }
  .main_box {
    margin-right: 5%;
    margin-left: 5%;
  }
}
</style>
